/*
 * @Author: your name
 * @Date: 2021-04-19 10:57:33
 * @LastEditTime: 2021-05-31 15:58:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \complex\app\router\mysql.js
 */
"use strict";

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller, middleware } = app;
  const jwt = middleware.jwt({...app.config.jwt,whitelist:app.config.auth.whitelist});
  const auth = middleware.auth(app.config.auth);
  const body2json = middleware.body2json(app.config.auth)
  router.post("/getAll/:db/:name", jwt, auth, controller.mysql.findAll);
  router.post("/get/:db/:name", jwt, auth, controller.mysql.find);
  router.post("/getOne/:db/:name", jwt, auth, controller.mysql.findOne);
  router.post("/get/:db/:name/:id", jwt, auth, controller.mysql.findById);
  router.post("/add/:db/:name", jwt, auth, body2json, controller.mysql.add);
  router.post("/edit/:db/:name", jwt, auth, body2json, controller.mysql.edit);
  router.post("/delete/:db/:name/:id", jwt, auth, controller.mysql.remove);
  router.post("/excute/:db/:name", jwt, auth, controller.mysql.excute);
  router.post("/tree/:db/:name/:field", jwt, auth, controller.mysql.tree);
};
